
package org.openhds.domain.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.openhds.domain.annotations.Description;
import org.openhds.domain.constraint.CheckInteger;
import org.openhds.domain.constraint.Searchable;


/**
 * Generated by JCodeModel
 * 
 */
@Description(description = "A Visit represents a Field Worker's observation of a specific Location within the study area at a particular date. It can be identified by a uniquely generated identifier which the system uses internally.")
@Entity
@Table(name = "visit")
@XmlRootElement
public class Visit
    extends AuditableCollectedEntity
    implements Serializable
{

    public final static long serialVersionUID = -211408757055967973L;
    @Searchable
    @Description(description = "External Id of the visit. This id is used internally.")
    private String extId;
    @Searchable
    @ManyToOne
    @Description(description = "Location that this visit is for.")
    private Location visitLocation;
    @NotNull(message = "You must provide a visit date")
    @Past(message = "Visit date should be in the past")
    @Temporal(TemporalType.DATE)
    @Description(description = "Date of the visit.")
    private Calendar visitDate;
    @CheckInteger(min = 1)
    @Description(description = "Round number for the visit.")
    private Integer roundNumber;
    @OneToMany(mappedBy = "entity", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @Description(description = "The assigned extension and their values specific for this entity.")
    private List<Extension> extensions = new ArrayList<Extension>();

    public String getExtId() {
        return extId;
    }

    public void setExtId(String id) {
        extId = id;
    }

    public Location getVisitLocation() {
        return visitLocation;
    }

    public void setVisitLocation(Location location) {
        visitLocation = location;
    }

    @XmlJavaTypeAdapter(org.openhds.domain.util.CalendarAdapter.class)
    public Calendar getVisitDate() {
        return visitDate;
    }

    public void setVisitDate(Calendar date) {
        visitDate = date;
    }

    public Integer getRoundNumber() {
        return roundNumber;
    }

    public void setRoundNumber(Integer roundNum) {
        roundNumber = roundNum;
    }

    public List<Extension> getExtensions() {
        return extensions;
    }

    public void setExtensions(List<Extension> list) {
        extensions = list;
    }

}
